package com.gancp.utills;

import com.gancp.common.Constans;
import com.github.pagehelper.PageHelper;
import com.sun.tools.internal.jxc.ap.Const;
import org.apache.commons.lang3.StringUtils;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by GCP on 2018/5/12.
 * 快速读取分页信息
 */
public class PageHelperUtils {

    private PageHelperUtils() {
    }

    /**
     * @Author gancp
     * @Date 时间被黑洞吸走了
     * @Descripition 快速分页工具类
     **/
    public static void execute(HttpServletRequest request) {
        String size = request.getParameter( Constans.VIEW_CURRENT_PAGE );
        String pageSizeStr = request.getParameter( Constans.VIEW_PAGE_SIZE );
        Integer pageSize = StringUtils.isEmpty( pageSizeStr ) ? 5 : Integer.valueOf( pageSizeStr );
        Integer startRow = StringUtils.isEmpty( size ) ? 0 : (Integer.valueOf( size ) - 1) * Integer.valueOf( pageSize );
        PageHelper.offsetPage( startRow, pageSize );
    }
}
